package com.example.controller;

import com.example.model.FormData;
import com.example.service.DemoService;
import com.example.utils.IdempotentUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/ttjeff")
public class DemoController {

    @Resource
    DemoService demoService;

    @RequestMapping("/test")
    public void test(){
        System.out.println("test");
    }

    @GetMapping("/route")
    public String yourHandler(FormData formData, HttpServletRequest request) {
        String url = request.getRequestURL().toString();  // 获取请求的URL
        //查看幂等性拦截是否生效
        if(IdempotentUtil.judge(url, formData, this.getClass())){
            System.out.println(1);
        }
        // Action层多例情况下可放到service层过滤
//        demoService.testIdempotentUtil(url,formData);
        return "Response";
    }
}